﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlPermissionOfUser.ascx.cs"
    Inherits="UserControl_ControlPermissionOfUser" %>
<%@ Register Assembly="DevExpress.Web.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%@ Import Namespace="webapp4U" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script src='<%=ResolveUrl("~/JScript/jquery-ui.min.js")%>' type="text/javascript"></script>
<script src='<%=ResolveUrl("~/JScript/JScript.js")%>' type="text/javascript"></script>

  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  
<script type="text/javascript">
    function pageLoad() {
        $("#accordion").accordion({ fillSpace: true, animated: 'bounceslide' });
        
        $("#<%= imgBtnAdd.ClientID %>").click(function() {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
        $("#<%= btnSave.ClientID %>").click(function() {
        if ($("#<%= txtTypeID.ClientID %>").val().length > 0 && $("#<%= txtTypeName.ClientID %>").val().length > 0) {
                $.blockUI({ css: {
                    border: 'none',
                    padding: '15px',
                    backgroundColor: '#000',
                    '-webkit-border-radius': '10px',
                    '-moz-border-radius': '10px',
                    opacity: .5,
                    color: '#fff'
                }
                });
            }
        });

        $("#<%= btSearch.ClientID %>").click(function() {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });
        $("#<%= imgBtnSave.ClientID %>").click(function() {
            $.blockUI({ css: {
                border: 'none',
                padding: '15px',
                backgroundColor: '#000',
                '-webkit-border-radius': '10px',
                '-moz-border-radius': '10px',
                opacity: .5,
                color: '#fff'
            }
            });
        });

        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args) {
            $.unblockUI();
        }
    }
//    $("#<%= ddlThuocNhom.ClientID %>").onchange(function() {
//        $.blockUI({ css: {
//            border: 'none',
//            padding: '15px',
//            backgroundColor: '#000',
//            '-webkit-border-radius': '10px',
//            '-moz-border-radius': '10px',
//            opacity: .5,
//            color: '#fff'
//        }
//        });
//    });
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    function EndRequestHandler(sender, args) {
        $.unblockUI();
    }

</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <dxpc:ASPxPopupControl ID="MessageBoxUserGroup" PopupHorizontalAlign="WindowCenter"  PopupVerticalAlign="WindowCenter" Font-Bold="true" HeaderText="Quản lý thông tin nhóm người dùng" 
            runat="server" Width="600px" Modal="true" ShowPageScrollbarWhenModal="true" ShowCloseButton="true" CloseAction="CloseButton" >                
                <ContentCollection>
                    <dxpc:PopupControlContentControl ID="PopupControlContentControl4" runat="server" SupportsDisabledAttribute="True">
                        <div >
                            <asp:ImageButton ID="imgBtnAdd" CausesValidation="false" ImageUrl="~/Images/add.png"
                                Width="32px" Height="32px" runat="server" OnClick="imgBtnAdd_Click" />                            
                        </div>
                        <!-- End Button chuc nang-->
                        <cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" BackColor="#CCFFFF"
                            Font-Names="Arial" Height="360px" Width="100%">                            
                            <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="Nhập thông tin" TabIndex="0">
                                <ContentTemplate>
                                    <!-- Content main-->
                                    <div class="direct_container_main">
                                        <div class="direct_container_form_right">
                                            <table border="0" width="100%">
                                            
                                                <tr>
                                                    <td colspan="4" align="center">
                                                        <asp:Label ID="lblMsg" runat="server" Visible="false" BackColor="Silver" ForeColor="Blue" Font-Bold="true" Font-Italic="true"></asp:Label>
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                    <td width="12%" align="right">
                                                        <p class="direct_label">
                                                            Mã nhóm<span>*</span></p>
                                                    </td>
                                                    <td width="88%" align="left">
                                                        <asp:TextBox ID="txtTypeID" CssClass="input_code" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ControlToValidate="txtTypeID" Display="None" ID="RFVTypeID"
                                                            runat="server" ErrorMessage="Phải nhập mã nhóm!">
                                                        </asp:RequiredFieldValidator>
                                                        <cc1:ValidatorCalloutExtender TargetControlID="RFVTypeID" ID="ValidatorCalloutExtender2"
                                                            runat="server">
                                                        </cc1:ValidatorCalloutExtender>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td align="right">
                                                        <p class="direct_label">
                                                            Tên nhóm<span>*</span></p>
                                                    </td>
                                                    <td align="left">
                                                        <asp:TextBox ID="txtTypeName" CssClass="input_full" runat="server"></asp:TextBox>
                                                        <asp:RequiredFieldValidator ControlToValidate="txtTypeName" Display="None" ID="RFVTypeName"
                                                            runat="server" ErrorMessage="Phải nhập tên nhóm!">
                                                        </asp:RequiredFieldValidator>
                                                        <cc1:ValidatorCalloutExtender TargetControlID="RFVTypeName" ID="ValidatorCalloutExtender1"
                                                            runat="server">
                                                        </cc1:ValidatorCalloutExtender>
                                                    </td>
                                                </tr>
                                                
                                                <tr>
                                                    <td align="right"><p class="direct_label"></p></td>
                                                    <td align="left">
                                                        <asp:Button ID="btnSave" runat="server" Text="Lưu" onclick="btnSave_Click" CausesValidation="true"/>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                    <!-- EndContent main-->
                                </ContentTemplate>
                            </cc1:TabPanel>
                            <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="Tìm kiếm" TabIndex="1">
                                <ContentTemplate>
                                    <!-- Content search-->
                                        <div class="direct_container_form_right">
                                            <table border="0" width="100%">
                                                
                                                <tr>     
                                                    <td>
                                                        <p class="direct_legend">
                                                            Nhập thông tin cần tìm</p>
                                                    </td>                                               
                                                    <td >
                                                        <asp:TextBox ID="txtSearch" CssClass="input_full" runat="server" Width="175"></asp:TextBox>
                                                        <asp:Button ID="btSearch" CausesValidation="false" CssClass="direct_bt_search" runat="server" Text="Tìm kiếm"
                                                            OnClick="btSearch_Click" />
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td colspan="3">
                                                        <asp:GridView ID="grvGroupUser" AllowPaging="true" 
                                                        PageSize="5" runat="server" AutoGenerateColumns="False" 
                                                            DataKeyNames="TypeID" OnPageIndexChanging="grvGroupUser_PageIndexChanging" 
                                                            OnRowCommand="grvGroupUser_RowCommand">
                                                            <Columns>
                                                                <asp:TemplateField HeaderText="Stt">
                                                                    <HeaderTemplate>
                                                                        STT
                                                                    </HeaderTemplate>
                                                                    <ItemTemplate>
                                                                        <%# Container.DataItemIndex + 1 %>
                                                                    </ItemTemplate>
                                                                    <HeaderStyle HorizontalAlign="Left" Width="50px" />
                                                                    <ItemStyle Height="30px" HorizontalAlign="Left" Width="50px" />
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="Mã nhóm">
                                                                    <HeaderTemplate>
                                                                        Mã nhóm
                                                                    </HeaderTemplate>
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblTypeID" runat="server" Text='<%# Eval("TypeID")%>'></asp:Label>
                                                                   
                                                                    </ItemTemplate>
                                                                    <HeaderStyle HorizontalAlign="Left" Width="150px" />
                                                                    <ItemStyle Height="30px" HorizontalAlign="Left" Width="150px" />
                                                                </asp:TemplateField>
                                                                <asp:TemplateField HeaderText="Nhóm người dùng">
                                                                    <HeaderTemplate>
                                                                        Nhóm người dùng
                                                                    </HeaderTemplate>
                                                                    <ItemTemplate>
                                                                        <asp:Label ID="lblTypeName" runat="server" Text='<%# Eval("TypeName")%>'></asp:Label>
                                                                    </ItemTemplate>
                                                                    <HeaderStyle HorizontalAlign="Left" Width="200px" />
                                                                    <ItemStyle Height="30px" HorizontalAlign="Left" Width="200px" />
                                                                </asp:TemplateField>
                                                                <asp:TemplateField>
                                                                    <ItemTemplate>
                                                                        <asp:ImageButton ID="imgBtnChon" runat="server" CausesValidation="False" 
                                                                            CommandName="chon" Height="25px" Width="25px" ImageUrl="~/Images/check.png" />
                                                                    </ItemTemplate>
                                                                    <ControlStyle BackColor="White" BorderColor="White" />
                                                                    <FooterStyle BackColor="White" BorderColor="White" />
                                                                    <HeaderStyle BackColor="White" BorderColor="White" />
                                                                    <ItemStyle BackColor="White" BorderColor="White" />
                                                                </asp:TemplateField>
                                                            </Columns>
                                                        </asp:GridView>
                                                    </td>
                                                </tr>
                                                </tr>
                                            </table>
                                        </div>
                                    <!-- End Content search-->
                                </ContentTemplate>
                            </cc1:TabPanel>
                        </cc1:TabContainer>                        
                                                
                    </dxpc:PopupControlContentControl>                
                </ContentCollection>
            </dxpc:ASPxPopupControl>  
        
    
        <div class="direct_container_right_titletop">
            Phân quyền người dùng
        </div>
        <hr />
        <!-- Button chuc nang-->
        <div class="direct_container_main">
            <asp:ImageButton ID="imgBtnSave" ImageUrl="~/Images/save.png" Width="32px" Height="32px"
                runat="server" OnClick="imgBtnSave_Click" ToolTip="Lưu"  CausesValidation="false" />
        </div>
        <!-- End Button chuc nang-->
        <div>
            <table style="width: 100%;">
                <tr>
                    <td align="left" width="15%">   
                        <p class="direct_label">
                            Thuộc nhóm
                        </p>
                    </td>                    
                </tr>
                <tr>
                    <td valign="top">
                        <asp:DropDownList ID="ddlThuocNhom" runat="server" AutoPostBack="True" 
                        OnSelectedIndexChanged="ddlThuocNhom_SelectedIndexChanged">
                        </asp:DropDownList>
                        <asp:Button ID="btnAddGroup" runat="server" Text="Thêm nhóm" onclick="btnAddGroup_Click" CausesValidation="false"/>
                        
                    </td>                    
                </tr>
                <tr>
                    <td>
                        <div id="accordion">
                            <asp:Repeater runat="server" ID="rptCategory">
                                <ItemTemplate>
                                       <h3><a href="#"><%# Eval("MenuName")%></a></h3>
	                            <div> 
                                    <p>
                                        <asp:GridView ID="gvMenuPage" runat="server" AutoGenerateColumns="False" 
                                            Width="100%" ShowFooter="True" DataSource='<%# tbListPageMenu((string)Eval("MenuID")) %>' >
                                            <Columns>
                                                <asp:TemplateField HeaderText="Chọn" ShowHeader="False">
                                                    <ItemTemplate>
                                                        <asp:CheckBox ID="checkPage"  runat="server" Checked='<%# Eval("IsChecked") %>' />
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        <input id="chkAll" title="Chọn hết" onclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
                                                        Chọn hết
                                                        <%--<asp:CheckBox ID="checkAll" runat="server" AutoPostBack="true" 
                                                            oncheckedchanged="checkAllQTHT_CheckedChanged" Text="Chọn hết" />--%>
                                                    </FooterTemplate>
                                                    <FooterStyle HorizontalAlign="Left" Width="100px" BackColor="#DBDBDB" ForeColor="Blue" />
                                                    <HeaderStyle Height="24px" Width="100px" />
                                                    <ItemStyle HorizontalAlign="Left" Width="100px" />
                                                </asp:TemplateField>
                                                <asp:BoundField HeaderText="Trang" DataField="PageName" >
                                                    <FooterStyle BackColor="#DBDBDB" />
                                                    <HeaderStyle HorizontalAlign="Left" />
                                                </asp:BoundField>
                                                
                                                <asp:TemplateField HeaderText="Chọn" ShowHeader="False" Visible=false>
                                                    <ItemTemplate>                                                        
                                                        <asp:Label ID="lblPageID"  runat="server" Text='<%# Eval("PageID") %>' />
                                                    </ItemTemplate>
                                                    
                                                    <FooterStyle HorizontalAlign="Left" Width="100px" BackColor="#DBDBDB" />
                                                    <HeaderStyle Height="24px" Width="100px" />
                                                    <ItemStyle HorizontalAlign="Left" Width="100px" />
                                                </asp:TemplateField>
                                                
                                                <asp:BoundField DataField="PageID" HeaderText="PageID" Visible="False" >
                                                    <FooterStyle BackColor="#DBDBDB" />
                                                </asp:BoundField>
                                                <asp:BoundField DataField="MenuID" HeaderText="MenuID" Visible="False" >
                                                    <FooterStyle BackColor="#DBDBDB" />
                                                </asp:BoundField>
                                            </Columns>
                                        </asp:GridView>
                                   </p>
                                </div>
                                </ItemTemplate>
                             </asp:Repeater>
                         </div>
                    </td>
                
                </tr>
            </table>
        </div>
        <dxpc:ASPxPopupControl ID="MessageBox" PopupHorizontalAlign="WindowCenter"  PopupVerticalAlign="WindowCenter" Font-Bold="true" HeaderText="DRM-S" runat="server" Height="91px" 
            Width="601px">
            <ContentCollection>
                <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True"></dxpc:PopupControlContentControl>
            </ContentCollection>
        </dxpc:ASPxPopupControl>
    </ContentTemplate>
</asp:UpdatePanel>
